﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_TrangChu : System.Web.UI.Page
{
    
    //Process process;
    //string strevenarg = "";
    TiemPhongDataContext db = new TiemPhongDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        /*if (!IsCallback)
        {
            if (Session["DangNhapAD"] == null)
                Response.Redirect("DangNhap.aspx");
            string callbackScript = "function CallServerData(arg,context){" + Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context", "Error", true) + ";}";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServerData", callbackScript, true);

            var NamMin = db.tbl_Tours.Min(t => t.DateGo);
            if (NamMin != null)
            {
               int n=NamMin.Value.Year;
                for (int i = n; i <= DateTime.Now.Year; i++)
                {
                    drlNam.Items.Add(new ListItem(i.ToString()));
                }
            }
            drlNam.SelectedValue = DateTime.Now.Year.ToString();
            
        }*/
    }

   /* public string GetCallbackResult()
    {
        if (Session["DangNhapAD"] == null)
            return "out";
        else
        {
            process = new Process(strevenarg, Server.MapPath("../"));

            return process.GetProcess();
        }
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        strevenarg = eventArgument;
    }*/
    protected void LinkButtonXoa_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        HiddenField hd = (HiddenField)lb.FindControl("HiddenFieldID");
        try
        {
            NguoiDung us = db.NguoiDungs.Single(u => u.NguoiDungId.Equals(hd.Value));
            db.NguoiDungs.DeleteOnSubmit(us);
            db.SubmitChanges();
            this.ListViewUser.DataSource = db.NguoiDungs.ToList();
            this.ListViewUser.DataBind();
            this.LabelMessage.Text = "Xóa User thành công";


        }
        catch
        {
            this.LabelMessage.Text = "Xóa User không thành công";
        }
    }
}